home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 726-750 / 745 / arexxbox / rxif / rx_cmdshell.c < prev    next >
C/C++ Source or Header  |  1995-03-18  |  2KB  |  86 lines

  1.  
  2. /*
  3.  * Dieses Kommando kann nur von ARexx aus eine CmdShell
  4.  * _ÖFFNEN_, und nur von einer CmdShell aus diese _SCHLIEßEN_.
  5.  *
  6.  * Mit etwas mehr Aufwand (Buchführung über die Hosts) kann man
  7.  * auch eine andere (flexiblere) Lösung finden.
  8.  *
  9.  * ACHTUNG: Buchführung über offene CmdShells ist zwingend
  10.  * notwendig für den CloseDown! Sonst bleiben nach 'Quit' u.U.
  11.  * noch CmdShells offen!
  12.  *
  13.  */
  14.  
  15. #include <dos/dostags.h>
  16.  
  17.  
  18. extern struct Library *SysBase, *DOSBase;
  19.  
  20.  
  21. static void runCommandShell( void )
  22. {
  23.     BPTR fh;
  24.     struct RexxHost *rh;
  25.     
  26.     /* diese Funktion wird als eigener Prozeß gestartet */
  27.     
  28.     geta4();
  29.     
  30.     if( rh = SetupARexxHost(NULL) )
  31.     {
  32.         if( fh = Open( "CON:////CommandShell/AUTO", MODE_NEWFILE ) )
  33.         {
  34.             CommandShell( rh, fh, fh, "> " );
  35.             Close( fh );
  36.         }
  37.         
  38.         CloseDownARexxHost( rh );
  39.     }
  40. }
  41.  
  42.  
  43. void rx_cmdshell( struct RexxHost *host, struct rxd_cmdshell **rxd, long action )
  44. {
  45.     struct rxd_cmdshell *rd = *rxd;
  46.  
  47.     switch( action )
  48.     {
  49.         case RXIF_INIT:
  50.             *rxd = calloc( sizeof *rd, 1 );
  51.             break;
  52.             
  53.         case RXIF_ACTION:
  54.             /* Insert your code HERE */
  55.             
  56.             if( rd->arg.close ) /* schließen */
  57.             {
  58.                 if( host->flags & ARB_HF_CMDSHELL )
  59.                 {
  60.                     host->flags &= ~ARB_HF_CMDSHELL;
  61.                 }
  62.                 else
  63.                 {
  64.                     rd->rc = -10;
  65.                     rd->rc2 = (long) "Not a CommandShell";
  66.                 }
  67.             }
  68.             else /* öffnen (OPEN ist unnötig) */
  69.             {
  70.                 CreateNewProcTags(
  71.                     NP_Entry, runCommandShell,
  72.                     NP_Name, "CommandShell",
  73.                     TAG_DONE );
  74.             }
  75.             
  76.             break;
  77.         
  78.         case RXIF_FREE:
  79.             /* FREE your local data HERE */
  80.             free( rd );
  81.             break;
  82.     }
  83.     return;
  84. }
  85.  
  86.